@extends('admin.container')

@section('c-head')
    <script type="text/javascript">

        var PAGE_DATA = {
            REST_API: {
                get_goods_classify_list: "{{route('admin.goods.category')}}",
                // 获取 [商品分类]列表数据
                new_goods_classify: "{{route('admin.goods.category.create')}}",
                // 编辑[商品分类]
            }
        };
    </script>
    @stop

@section('c-body')
    <div class="comm-title">
                    <span class="title-msg">
                        商品分类
                    </span>
    </div>
    <div class="comm-body">
        <div class="tool-bar-top clearfix" style="padding-top:25px;">
            <a id="new-classify-btn" class="am-btn am-btn-success am-btn-xs"
               style="float:left;">
                新增
            </a>
        </div>
        <table class="am-table am-table-striped am-table-hover am-table-centered admin-comm-tbl "
               style="">
            <thead>
            <tr>
                <th>
                                    <span style="visibility:hidden;">
                                        icon
                                    </span>
                </th>
                <th>
                    排序
                </th>
                <th>
                    分类名称
                </th>
                <th>
                    新增下级
                </th>
                <th>
                    操作
                </th>
            </tr>
            </thead>
            <tbody id="good-classify-context" class="good-classify-tbody">


            <tr style="visibility:hidden;">
                <td style="width:5%;">
                    <span class="icon-plus" style="visibility:hidden;"> </span>
                </td>
                <td>
                                    <span class="am-badge am-badge-b2b am-text-default">

                                    </span>
                </td>
                <td class="classify-name">
                                    <span class="am-badge am-badge-b2b am-text-default" style="margin-left: 20%;" title="分类名称1分类名称2分类名称3">

                                    </span>
                </td>
                <td>
                    <button type="button" class="sel-new-btn am-btn am-btn-success am-btn-xs mid"
                            style="position:relative;top: 15px; visibility:hidden;">
                        <i class="icon-plus">
                        </i>

                    </button>
                </td>
                <td>
                    <div class="mid" style="position: relative;top:15px;width:110px;">
                        <button type="button" class="sel-edit-btn am-btn am-btn-primary am-btn-xs"
                                style="float:left;">
                            编辑
                        </button>
                        <button type="button" class="sel-del-btn am-btn am-btn-default am-btn-xs"
                                style="float:left; margin-left:10px;">
                            删除
                        </button>
                    </div>
                </td>
            </tr>

            </tbody>
        </table>
        <div id="comm-paging" class="admin-paging" >
        </div>
    </div>
    <script type="text/template" id="tbl-list-templ">

        <% _.each(obj, function(item) { %>
        <tr>
            <td style="width:5%" class="sel-fold" data-id="<%=item.id %>">
                <span class="icon-plus" <%if(!item.hasChildren || item.hasChildren.length == 0){%> style="visibility:hidden;" <%} %>></span>
            </td>
            <td>
        <span class="am-badge am-badge-b2b am-text-default">
            <%=item.sort %>
        </span>
            </td>
            <td class="classify-name">
        <span class="am-badge am-badge-b2b am-text-default" style="" title="<%=item.name %>">
            <%=item.name %>
        </span>
            </td>
            <td>
                <a type="button" class="sel-new-btn am-btn am-btn-success am-btn-xs"
                   style="" href="<%=item.new_href %>" data-id="<%=item.id %>" >
                    <i class="icon-plus"></i>
                    新增下级
                </a>
            </td>
            <td>
                <div class="mid clearfix" style="position: relative;top:15px;width:110px;">
                    <a type="button" class="sel-edit-btn am-btn am-btn-primary am-btn-xs"
                       style="float:left;" href="<%=item.edit_href %>">
                        编辑
                    </a>
                    <button type="button" class="sel-del-btn am-btn am-btn-default am-btn-xs"
                            style="float:left; margin-left:10px;" href="<%=item.delete_href %>">
                        删除
                    </button>
                </div>
            </td>
        </tr>

        <% _.each(item.hasChildren, function(childItem) {   %>

        <tr  data-parent-id="<%=item.id %>" style="display: none;" >
            <td style="width:5%" class="">
                <span class="icon-minus" style="visibility:hidden;"> </span>
            </td>
            <td>
        <span class="am-badge am-badge-b2b am-text-default">
            <%=childItem.sort %>
        </span>
            </td>
            <td class="classify-name">
        <span class="am-badge am-badge-b2b am-text-default" style="margin-left: 20%;" title="<%=childItem.name %>">
            <%=childItem.name %>
        </span>
            </td>
            <td>
                <button type="button"
                        class="am-btn am-btn-success am-btn-xs mid"
                        style="position:relative;top: 15px; visibility:hidden;">
                    <i class="icon-plus"> </i>
                    新增下级
                </button>
            </td>
            <td>
                <div class="mid clearfix" style="position: relative;top:15px;width:110px;">
                    <a type="button" class="sel-edit-btn am-btn am-btn-primary am-btn-xs"
                       style="float:left;" href="<%=childItem.edit_href %>">
                        编辑
                    </a>
                    <button type="button" class="sel-del-btn am-btn am-btn-default am-btn-xs"
                       style="float:left; margin-left:10px;" href="<%=childItem.delete_href %>" >
                        删除
                    </button>
                </div>
            </td>
        </tr>
        <% }); %>

        <% }); %>
    </script>

    <script src="/assets/b2b/admin/js/pages/03.js">
    </script>
@stop